import 'package:flutter/material.dart';

class MyTextField extends StatefulWidget {
  final ValueChanged<String>? onChanged;
  final String? value;
  const MyTextField({super.key, this.onChanged, this.value = ''});

  @override
  State<MyTextField> createState() => _MyTextFieldState();
}

class _MyTextFieldState extends State<MyTextField> {
  final _controller = TextEditingController();

  void initState() {
    super.initState();
    _controller.addListener(() {
      widget.onChanged?.call(_controller.text);
    });
  }

  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: _controller,
      onChanged: (value) {},
      style: TextStyle(fontSize: 14),
      textAlign: TextAlign.right,
      decoration: InputDecoration(
        // contentPadding: EdgeInsets.symmetric(vertical: 0.0), // 垂直内边距
        hintText: '请输入您的用户名',
        border: InputBorder.none,
      ),
    );
  }
}
